package cn.com.idmy.base.exception;

import cn.com.idmy.base.config.DefaultConfig;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.dromara.hutool.core.text.StrUtil;

@Getter
@Setter
@Accessors(fluent = true, chain = true)
public class BizException extends RuntimeException {
    protected int code = DefaultConfig.defaultErrCode;
    protected boolean processable;
    protected String hint;
    protected Object data;

    public BizException data(Object data) {
        this.data = data;
        return this;
    }

    public BizException(String message) {
        super(message);
    }

    public BizException(String message, Object... params) {
        super(StrUtil.format(message, params));
    }

    public BizException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BizException(int code, String message, Object... params) {
        super(StrUtil.format(message, params));
        this.code = code;
    }

    public BizException(Throwable cause, int code, String message) {
        super(message, cause);
        this.code = code;
    }

    public BizException(Throwable cause, int code, String message, Object... params) {
        super(StrUtil.format(message, params), cause);
        this.code = code;
    }

    public BizException(String message, Throwable cause) {
        super(message, cause);
    }

    public BizException(Throwable cause) {
        super(cause);
    }
}
